<-- back

Excel Sheet Column Number

Link

Straightforward question. Just look what place the character is at and what character it is, and deterimine it's value from there.

Full Solution in Java:

public class Solution { public int titleToNumber(String s) { int result = 0; int place = 0; for(int i=s.length()-1; i>=0; i--){ result+=(int)(Math.pow(26,place))*(s.charAt(i)-64); place++; } return result; } }